/**
 * 
 */
package com.Hib.Recipes;

import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import com.Hib.Domain.Book2;
import com.Hib.Util.SessionManager;

/**
 * @author Ignatiues charles arun
 * 
 *         Aug 29, 2010
 */
public class BookDAO2
	{

		private static SessionFactory sessionFactory;

		/**
		 * @param args
		 * @throws ParseException
		 */
		public static void main(String[] args) throws ParseException
			{
				// TODO Auto-generated method stub

				final Calendar rightNow = Calendar.getInstance();

				sessionFactory = getSession();
				Session session = sessionFactory.getCurrentSession();
				session.beginTransaction();
				// SimpleDateFormat simpDate = new
				// SimpleDateFormat("dd-MM-yyyy");
				java.util.Date dtObj = null;
				dtObj = new Date();
				Book2 book2, book2_test = null;
				book2 = new Book2();
				// book2.setIsbn(new Long(129));
				book2.setName("Spring Book ++++");
				// book2.setPublishDate(dtObj);
				// book2_test = new Book2();
				// book2_test.setIsbn(new Long(127));
				// book2_test.setName("Spring Book ++++");

				// book2.setName("+++");
				// book2.setPublishDate(dtObj);
				//
				// Book2 boo2_obj2 = (Book2) session.get(Book2.class, book2
				// .getIsbn());
				// if (boo2_obj2.equals(boo2_obj2))
				// {
				// System.out.println("Both objects have same values...");
				// } else
				// {
				// System.out.println("Have distinct values...");
				// }

				// session.save(book2);
				session.saveOrUpdate(book2);
				session.beginTransaction().commit();
				// session.close();

			}

		private static SessionFactory getSession()
			{
				sessionFactory = SessionManager.getSessionfactory();
				return sessionFactory;

			}
	}
